package leetcode.秋招.腾讯;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2021/9/5 21:14
 * @description：
 */
public class Main3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int l = in.nextInt();
        int r = in.nextInt();
        Queue<Integer> queue = new LinkedList<>();
        StringBuilder builder = new StringBuilder();
        builder.append(n);
        queue.offer(n);
        while (!queue.isEmpty()) {
            int size = queue.size();
            for (int i = 0; i < size; i++) {
                Integer cur = queue.poll();
                StringBuilder sub = new StringBuilder();
                int factor = cur / 2;
                int f = cur % 2;
                sub.append(factor).append(f).append(factor);
                if (factor > 1) {
                    queue.offer(factor);
                }
                if (f > 1) {
                    queue.offer(f);
                }
                builder = new StringBuilder(builder.toString().replace("" + cur, sub.toString()));
            }
        }
        char[] chars = builder.toString().toCharArray();
        int count = 0;
        for (int i = l - 1; i < r; i++) {
            if (chars[i] == '1') count++;
        }
        System.out.println(count);
    }
}
